All Questions
48 questions
0votes
1answer
104views
Bash Shebang scripts with a .ksh extention
I have inherited shell scripts that have a bash shebang...but for some reason have a .ksh extension. The creator of these scripts is no longer here and I cant find any reason in Google. Why would he ...
2votes
1answer
465views
if var='value' then in Zsh: Is it really a valid syntax without semicolon?
The following code works on Zsh 5.8 that I tried, despite the missing semicolon. But is it really a valid Zsh syntax? #!/bin/zsh if var='value' then echo 'then' fi Without an assignation that ...
3votes
1answer
416views
Why is "${1-"$var"}" (option 6 down below) not mentioned in POSIX?
The only reference I could find in the spec is this: It would be desirable to include the statement "The characters from an enclosed "${" to the matching '}' shall not be affected by ...
0votes
3answers
1kviews
Concatenate files with same structure, keeping header only for 1st file
I want to merge 28 files with different names and the same data structure, using the script below: $ cp mohan.csv Consolidate.csv $ for fname in line do cat $fname | sed '1d' >> ...
0votes
1answer
462views
Using Heredoc with command substitution referring to the shell PID differs between ksh and bash
Korn script: #!/bin/ksh sqlplus -s / << EOF define a=$(pgrep -P $$) define a !ptree &a EOF VS Bash script: #!/bin/bash sqlplus -s / << EOF define a=$(pgrep -P $$) define a !ptree &...
0votes
1answer
202views
Error in script to check(or wait) for availability of file in directory
I want to write a shell script that checks if trigger file is available in my directory or not. If not available I want the code to wait for, say 1 hour, and check again for availability until found. ...
3votes
1answer
1kviews
Bash Script : Problem with variables from csv file
I'm having a little problem getting variables from a csv file on my Linux machine and using them in an if. I have the following csv: Name;Age Marc;18 Joseph;10 I'm trying to get this information from ...
0votes
1answer
487views
Migrate shells Solaris ksh to Red Hat
We have hundreds of shell scripts running on a Solaris 11.3 server. System shell is ksh93 $ ls -l /bin/sh lrwxrwxrwx 1 root root 13 Apr 12 2018 /bin/sh -> sparcv9/ksh93 All the ...
-1votes
2answers
2kviews
Convert array into string
I have a string say, test_var=ab_c_de_fg_.txt. I need to store ab_c in one variable (characters before the 2nd _) and de_fg_ in a second variable (characters after the second _ and before .txt), so ...
1vote
2answers
3kviews
Compare two files based on key, print difference in value in another file in Bash Shell Script
Need help on shell script, I have 2 large files around 1.2 GB data, with key and values, I need to compare both files based on the key and store difference in the value in the third file and the ...
0votes
1answer
196views
display time per minute using start and end date time
I want to write a script that will display the time per minute between two date and time. The Start and End time gap can be anything, could be 5minutes, 3hours, 30days, etc. Example: Start time: ...
0votes
2answers
235views
Korn shell and Bash substitute variable with space over SSH
I have been trying to collect the LPAR id details in by executing a remote command from AIX server (Korn Shell) to IBM HMC (restricted Bash Shell) over SSH. Im having trouble in substituting the ...
1vote
1answer
26kviews
/bin/ksh: bad interpreter: No such file or directory [duplicate]
I have script with #!/bin/ksh in the first line. When I try to execute this script (run ./myscript.sh) the error occurred: -bash: ./myscript.sh: /bin/ksh: bad interpreter: No such file or directory ...
5votes
2answers
2kviews
Is there a way to make the local command work portably to dash ksh bash and zsh?
In dash (and in bash zsh and some other shells) the command local works to make a variable scope limited to that function (and descendants in some cases). That enable the possibility of making a ...
1vote
1answer
124views
Unable to find regular file with default shell as bash but works when it's ksh
We have script file FileChecker.sh where it checks whether file exists or not FileChecker.sh content: #!/bin/ksh FILE=$1 FILE2=$2 if [[ "$FILE" == "" || "$FILE2" == "" ]] ; then echo "[ERROR] ...